package com.derbysoft.defender.mp.api;

import com.derbysoft.defender.mp.api.response.ApiResponse;

import java.util.Map;

/**
 * <p>some description here.</p>
 * Created by Afee Lee on 2017-03-20 22:24
 *
 * @author Afee Lee
 * @version 1.0
 * @see Object
 * @since 1.8
 */
public class ApiRequestException extends RuntimeException {
    private int statusCode;

    private Map<String, String> httpHeaders;

    private ApiResponse apiResponse;

    public ApiRequestException(String message) {
        super(message);
    }

    public ApiRequestException(String message, Throwable cause) {
        super(message, cause);
    }

    public int getStatusCode() {
        return statusCode;
    }

    public Map<String, String> getHttpHeaders() {
        return httpHeaders;
    }

    public ApiResponse getApiResponse() {
        return apiResponse;
    }

    public ApiRequestException statusCode(int statusCode) {
        this.statusCode = statusCode;
        return this;
    }

    public ApiRequestException httpHeaders(Map<String, String> httpHeaders) {
        this.httpHeaders = httpHeaders;
        return this;
    }

    public ApiRequestException apiResponse(ApiResponse apiResponse) {
        this.apiResponse = apiResponse;
        return this;
    }

    @Override
    public String toString() {
        return getClass().getName() + "{" +
                "statusCode=" + statusCode +
                ", httpHeaders=" + httpHeaders +
                ", apiResponse=" + apiResponse +
                '}';
    }
}
